<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
                'id' => 'version-form',
                'enableClientValidation' => true,
                'clientOptions' => array(
                    'validateOnSubmit' => true,
                    ),
                'htmlOptions'=>array(
                    'enctype'=>'multipart/form-data',
                ),    
            ));
    ?>


    <?php echo CHtml::errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'name'); ?>
        <?php echo $form->textField($model, 'name', array('size' => 80, 'maxlength' => 128)); ?>
        <?php echo $form->error($model, 'name'); ?>
    </div>
    <div class="row">
        <?php echo "<label for='cate'>Cate</label>"; ?>
        <?php
        echo Chtml::dropDownList("cate", 0, Lookup::items('software_cate'), array(
            'ajax' => array(
                'type' => 'POST', //request type
                'url' => CController::createUrl('version/getsw'), //url to call.
                'dataType'=>'json',
                'data'=>array('cate'=>'js: $(this).val()'),
                //'update' => '#Version_sw_id', //selector to update
                'success' => 'function(data) {
                            $("#Version_sw_id").html(data.sw);
                }'
                )));
        ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'sw_id'); ?>
        <?php echo $form->dropDownList($model, 'sw_id', $this->getSw(),array()); ?>
        <?php echo $form->error($model, 'sw_id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'file_upload'); ?>
        <?php echo $form->fileField($model, 'file_upload'); ?>
        <?php echo $form->error($model, 'file_upload'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->
